package com.star.dao;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.star.model.NewsModel;
import com.star.utils.PageQuery;

public interface NewsDao {
	@Select("SELECT * FROM t_news order by gmt_create desc limit #{pageStar},#{pageSize}")
	List<NewsModel> getNewsPageQuery(PageQuery pageQuery);

	@Select("SELECT * FROM t_news where content like concat('%',#{search},'%')  order by gmt_create desc limit #{pageStar},#{pageSize}")
	List<NewsModel> getNewsSearchPageQuery(@Param("search") String search, @Param("pageStar") Integer pageStar,
			@Param("pageSize") Integer pageSize);

	@Select("SELECT * FROM t_news WHERE id = #{id} ")
	NewsModel getNewsModel(@Param("id") Integer id);

	@Select("SELECT * FROM t_news WHERE key_news_id = #{keyId}")
	List<NewsModel> queryNewsByKeyId(@Param("keyId") Integer keyId);

	@Select("SELECT * FROM t_news where gmt_create  >= #{date} order by gmt_create desc limit #{pageStar},#{pageSize}")
	List<NewsModel> getNewsPageQueryByDate(@Param("date") Date date, @Param("pageStar") Integer pageStar,
			@Param("pageSize") Integer pageSize);

	@Select("SELECT * FROM t_news where  content like concat('%',#{search},'%') and  gmt_create  >= #{date} order by gmt_create desc limit #{pageStar},#{pageSize}")
	List<NewsModel> getNewsSearch(@Param("date") Date date, @Param("search") String search,
			@Param("pageStar") Integer pageStar, @Param("pageSize") Integer pageSize);

}
